﻿using MiddlewareTest.MiddlewareDelegate;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace MiddlewareTest.Middleware
{
    public abstract class BaseMiddleware : IMiddleware
    {
        protected readonly IServiceProvider _serviceProvider;
        public BaseMiddleware(IServiceProvider service)
        {
            _serviceProvider = service;
        }
        public RequestDelegate Invoke(RequestDelegate next)
        {
            return async context =>
            {
                Execution(context);
                await next(context);
                Executed(context);
            };
        }

        public abstract void Execution(RequestContext context);

        public abstract void Executed(RequestContext context);
    }
}
